package com.wframe.project.former.web.order;

import java.util.Date;

import com.frame.database.JdataBean;
import com.frame.pageform.DataPageForm;
import com.frame.pageform.annotation.Login;
import com.wframe.project.former.dataservices.order.OrderService;
import com.wframe.project.former.dataservices.user.UserService;
import com.wframe.project.jnd.extinterface.sms.SmsUtil;

@Login
public class OrderPage extends DataPageForm{
	
	private JdataBean bean;
	private OrderService orderService=OrderService.getIntance();

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		setPagination(orderService.queryOrder(bean, getPageSize_(), getPageNum()));
		return "/webadmin/order/orderList.jsp";
	}
	@Override
	public String show() throws Exception {
		// TODO Auto-generated method stub
		bean=orderService.getOrderInfo(bean.getString("id"));
		return "/webadmin/order/orderInfo.jsp";
	}
	
	public String fahuoShow(){
		bean.put("send_time", new Date());
		return "/webadmin/order/fahuo.jsp";
	}
	
	public String fahuo() throws Exception{
		orderService.fahuo(bean.getString("id"), bean.getString("send_time"), bean.getString("expres_type"), bean.getString("expres_code"));
		JdataBean order=orderService.getBean(bean.getString("id"));
		JdataBean user=UserService.getIntance().getBean(order.getString("userid"));
		new SmsUtil().sendOrderShip(user.getString("phone"),order.getString("code"), user.getString("title"));
		getJsonObject().getJsonPage().closeWin("ok");
		return getJsonObject().toString();
	}
	
	public String backorders() throws Exception{
		setPagination(orderService.queryBackOrder(bean, getPageSize_(), getPageNum()));
		return "/webadmin/order/backorderlist.jsp";
	}
	
	public String backorderinfo() throws Exception{
		bean=orderService.getBackOrderInfo(bean.getString("id"));
		return "/webadmin/order/backorderinfo.jsp";
	}
	
	public String tuihauthShow(){
		
		return "/webadmin/order/backorderauth.jsp";
	}
	
	public String backorderauth() throws Exception{
		orderService.backorderauth(bean.getString("orderid"),bean.getInt("status"),bean.getString("content"));
		getJsonObject().getJsonPage().closeWin("ok");
		return getJsonObject().toString();
	}
	public String orderconfirm() throws Exception{
		orderService.orderconfirm(bean.getString("orderid"));
		return getJsonObject().toString();
	}

	@Override
	public String toDel() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean toUpdate() throws Exception {
		// TODO Auto-generated method stub
		return false;
	}
	public JdataBean getBean() {
		return bean;
	}
	public void setBean(JdataBean bean) {
		this.bean = bean;
	}

	
}
